package com.example.fragmenttest

import android.os.Bundle
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment

class MainActivity : AppCompatActivity() {
//    lateinit var left_btn1: Button
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

       /* left_btn1 = findViewById(R.id.left_btn1)

        left_btn1.setOnClickListener {
            replaceFragment(AnotherRightFragment())
        }

        replaceFragment(RightFragment())*/
    }

    /*// 动态添加Fragment
    private fun replaceFragment(fragment: Fragment){
        val fragmentManager = supportFragmentManager
        val transaction = fragmentManager.beginTransaction()
        transaction.replace(R.id.rightLayout, fragment)
        transaction.addToBackStack(null)         // 将一个事务添加到返回栈，这样点击back键就能返回到上一个Fragment
        transaction.commit()
    }*/
}